package day_2023_7_to_10;

/**
 * @author haomin
 * @date 2023/08/16 22:24
 **/
public class Day_8_16 {
    class Solution {
        public double myPow(double x, int n) {
            double ans = 1.0;
            for(int i = n; i != 0; i /= 2){
                if(i % 2 != 0) ans *= x;
                x *= x;
            }
            return n < 0 ? 1/ans : ans;
        }
    }
}